export default {
  // 为当前模块开启命名空间
  namespaced: true,
  
  state: ()=> ({
    address: JSON.parse(uni.getStorageSync('address') || '{}')
  }),
  
  mutations: {
    //更新收货地址
    updateAddress(state, address){
      state.address = address;
      this.commit('m_user/saveAddresstoStorage')
    },
    saveAddresstoStorage(state){
      uni.setStorageSync('address', JSON.stringify(state.address))
    }
  },
  
  getters: {
    addressString(state){
      if(!state.address.provinceName){
        return '';
      }
      /*cityName: "广州市"
      countyName: "海珠区"
      detailInfo: "新港中路397号"
      errMsg: "chooseAddress:ok"
      nationalCode: "510000"
      postalCode: "510000"
      provinceName: "广东省"
      telNumber: "020-81167888"
      userName: "张三" */
     return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
    }
  }
}